
Phone = {}

function Phone:Parse(buffer)
	while true do
		local tag = buffer:ReadTag()
		if tag == 0 then
			return

		elseif tag == 1 then
			if self.num == nil then
				self.num = {}
			end
			
			local temp = buffer:ReadString()

			table.insert(self.num, temp)

		end
	end
end

function Phone:Serialize()
	local buf = {}
	SetIndex(buf, WriteBuffer)
	buf:Init()

	
	if self.num ~= nil then
		for k, v in ipairs(self.num) do
			
			buf:WriteString(1, v)

		end
	end

	return buf
end

Person = {}

function Person:Parse(buffer)
	while true do
		local tag = buffer:ReadTag()
		if tag == 0 then
			return

		elseif tag == 1 then
			if self.id == nil then
				self.id = {}
			end
			
			local temp = buffer:ReadInt()

			table.insert(self.id, temp)

		elseif tag == 2 then
			self.name = buffer:ReadString()

		elseif tag == 3 then
			self.email = buffer:ReadString()

		elseif tag == 4 then
			local msgObj = {}
			SetIndex(msgObj, Phone)
			self.phone = buffer:ReadMsg(msgObj)

		elseif tag == 5 then
			if self.phone1 == nil then
				self.phone1 = {}
			end
			
			local msgObj = {}
			SetIndex(msgObj, Phone)
			local temp = buffer:ReadMsg(msgObj)

			table.insert(self.phone1, temp)

		end
	end
end

function Person:Serialize()
	local buf = {}
	SetIndex(buf, WriteBuffer)
	buf:Init()

	
	if self.id ~= nil then
		for k, v in ipairs(self.id) do
			
			buf:WriteInt(1, v)

		end
	end

	if self.name ~= nil then
		buf:WriteString(2, self.name)
	end

	if self.email ~= nil then
		buf:WriteString(3, self.email)
	end

	if self.phone ~= nil then
		buf:WriteMsg(4, self.phone)
	end

	if self.phone1 ~= nil then
		for k, v in ipairs(self.phone1) do
			
			buf:WriteMsg(5, v)

		end
	end

	return buf
end
